<?php
  include('lock.php');
  $id=$_POST['paidID'];
  
  $q1="INSERT INTO history (history_ID, order_total_price, order_date, order_status, location_ID, user_ID) SELECT order_ID, order_total_price, order_date, 'Paid', location_ID, user_ID from `order` where order_ID = '$id'";
  mysql_query($q1);
  
  $sql="SELECT * From order_game where order_ID = '$id'";
  $result=mysql_query($sql);
  while($row=mysql_fetch_array($result))
  {
  echo $order_game_ID=$row['order_game_ID'];
  echo $game_ID=$row['game_ID'];
  echo $game_price=$row['game_price'];
  $q2="INSERT INTO history_game (history_game_ID, game_ID, game_price, history_ID) Values ('$order_game_ID', '$game_ID', '$game_price', '$id')";
  mysql_query($q2);
  }
  
  
  $q3="DELETE FROM `order` where order_ID='$id'";
  mysql_query($q3);
  
  header('Location: AdminOrder.php');
?>